import React, {
  useContext, useEffect, useMemo, useState
} from 'react';
import { useReModel } from '@/utils';

type Store = {
  lang: Lang;
  setLang: (lang: Lang) => void;
};

const store: Store = {
  lang: 'zh',
  setLang: () => {},
};

const GlobalContext = React.createContext(store);

const useStore = () => useContext(GlobalContext);

const Provider: React.FC = props => {
  const { state } = useReModel(store);

  return <GlobalContext.Provider value={state}>{props.children}</GlobalContext.Provider>;
};

export { Provider, useStore };
